package cn.itcast.com.homework.day727;



/*
2.  定义三种新类型的异常。
    写一个类，在该类的三个方法中抛出三种不同的异常。
    然后在mian方法中调用这个类的不同方法，尝试用try catch捕获你写的异常。
 */
public class test2 {
    public static void main(String[] args)  {
        ExceptionBoss boss = new ExceptionBoss();
        try {
            boss.getruntimeException();
        }catch (runtimeException r){
            System.out.println(r.getMessage());
        }

        try {
            boss.getcheckableScoreException1();
        }catch (checkableScoreException1 c){
            System.out.println(c.getMessage());
        }

        try {
            boss.getcheckableScoreException2();
        }catch (checkableScoreException2 c){
            System.out.println(c.getMessage());
        }
        System.out.println("sd");
    }


}
class ExceptionBoss{
    public void getruntimeException(){
        throw  new runtimeException("第一种");
    }

    public void getcheckableScoreException1() throws checkableScoreException1 {
        throw new checkableScoreException1("第二种");
    }
    public void getcheckableScoreException2() throws checkableScoreException2 {
        throw new checkableScoreException2("第三种");
    }
}
//运行时异常
class runtimeException extends RuntimeException{
    public runtimeException(String message) {
        super(message);
    }
}
//编译时异常
class checkableScoreException1 extends Exception{
    public checkableScoreException1(String message) {
        super(message);
    }
}
//编译时异常
class checkableScoreException2 extends Exception{
    public checkableScoreException2(String message) {
        super(message);
    }
}
